package com.koala.learn.paramslearn;

import lombok.Data;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;

import java.util.Optional;

/**
 * @author yantingrui
 * @date 2021/12/30   15:54
 */
@Data
public class MyPage extends PageRequest {

    private String myPageMsg;

    /**
     * Creates a new {@link PageRequest} with sort parameters applied.
     *
     * @param page zero-based page index, must not be negative.
     * @param size the size of the page to be returned, must be greater than 0.
     * @param sort must not be {@literal null}, use {@link Sort#unsorted()} instead.
     */
    protected MyPage(int page, int size) {
        super((Integer) Optional.ofNullable(page).orElse(1), (Integer) Optional.ofNullable(size).orElse(10), Sort.by(new String[]{"id"}).descending());
    }

    public MyPage() {
        super(1, 20, Sort.by(new String[]{"id"}).descending());
    }


    //public String getMsg() {
    //    System.out.println("----mypage----getMsg--");
    //    return msg;
    //}
    //
    //public void setMsg(String msg) {
    //    System.out.println("----mypage----setMsg--");
    //    this.msg = msg;
    //}
}
